package com.wpw.dream.thread;

public class InterruptedExceptionTest {
	
	public static void main(String[] args) throws InterruptedException {
		ThreadA a = new ThreadA();
		a.start();
		Thread.sleep(2000);
		a.interrupt();
		System.out.println("a:" + a.isInterrupted());
	}
	

}

class ThreadA extends Thread {

	@Override
	public void run() {
		while (!Thread.currentThread().isInterrupted()) {
			System.out.println("正在执行");
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {//状态位被清除
				e.printStackTrace();
				System.out.println("该线程：" + Thread.currentThread().isInterrupted());
				Thread.currentThread().interrupt();
			}
		}
	}
	
}
